#include "suspendscrollbar.h"
#include <QFile>

SuspendScrollBar::SuspendScrollBar(QWidget *parent) : QScrollBar (parent)
{
    this->setOrientation(Qt::Orientation::Vertical);
    QString stylePath = ":qss/scrollbar.qss";
    QFile styleFile(stylePath);
    if (styleFile.open(QFile::ReadOnly)) {
        QString style(styleFile.readAll());
        setStyleSheet(style);
    }
    this->setRange(0, 0);
    this->hide();
}

SuspendScrollBar::~SuspendScrollBar()
{

}

void SuspendScrollBar::slotValueChanged(int value)
{
    this->setValue(value);
}

void SuspendScrollBar::slotRangeChanged(int min, int max)
{
    this->setMinimum(min);
    this->setRange(0, max);
    double step = 0.75 * (height() + max);
    this->setPageStep(static_cast<int>(step));
    if (max <= 0) {
        this->hide();
    }
}
